<template>
  <sea-net-frame url="/api/mapping/page" disabled-form>

    <!-- form-header -->
    <template #title>
      <sea-table-title title="系统接口分组" subtitle="包含所有 Controller 的信息"></sea-table-title>
    </template>

    <!-- data-panel -->
    <template #default="{list}">
      <sea-dialog ref="dialog">
        <parameter ref="parameter" :object="row_data"></parameter>
      </sea-dialog>

      <el-table :data="list">
        <sea-col-link property="controllerClass" label="归属类" width="360" :click="onAction"></sea-col-link>
        <el-table-column property="methodName" label="方法名" width="160" :click="onAction"></el-table-column>
        <el-table-column property="requestMethod" label="请求方式" width="80"></el-table-column>
        <el-table-column property="requestMapping" label="请求路径" width="260"></el-table-column>
        <el-table-column property="description" label="描述" show-overflow-tooltip></el-table-column>
      </el-table>
    </template>
  </sea-net-frame>
</template>

<script>
import Parameter from "./parameter.vue";

/**
 * 展示后台所有 request-mapping 配置信息
 */
export default {
    components: {Parameter},
    data() {
        return {
            // 操作名称
            operation: undefined
            // 当前操作的行级对象
            , row_data: undefined
        }
    },
    methods: {
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         */
        onAction: function (evt, row) {
            this.operation = evt;
            if (evt === '$controllerClass') {
                let dialog = {title: row.description, fullscreen: true};
                this.$refs.dialog.open(dialog).then(() => {
                    this.$refs.parameter.setRowData(row);
                });
            }
        }
    }
}
</script>
